package com.bf.electroplating.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bf.electroplating.pojo.dto.IdDTO;
import com.bf.electroplating.pojo.dto.contingency.ContingencySpaceFacilityDTO;
import com.bf.electroplating.pojo.dto.contingency.ContingencySpaceFacilityQueryDTO;
import com.bf.electroplating.pojo.vo.ResultVO;
import com.bf.electroplating.pojo.vo.contingency.ContingencySpaceFacilityVO;
import com.bf.electroplating.service.ComContingencySpaceFacilityService;
import com.bf.electroplating.util.idempotent.Idempotent;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 应急空间与设施管理控制器
 */
@RestController
@RequestMapping ( "/com-contingency-space-facility" )
@Tag ( name = "应急空间与设施管理", description = "应急空间与设施管理相关接口" )
public class ComContingencySpaceFacilityController {

	@Resource
	private ComContingencySpaceFacilityService contingencySpaceFacilityService;

	@PostMapping ( "/page" )
	@Operation ( summary = "分页查询应急空间与设施列表", description = "分页查询应急空间与设施列表" )
	public ResultVO < Page < ContingencySpaceFacilityVO > > pageList ( @RequestBody ContingencySpaceFacilityQueryDTO queryDTO ) {
		return contingencySpaceFacilityService.pageList ( queryDTO );
	}

	@Idempotent
	@PostMapping ( "/saveData" )
	@Operation ( summary = "新增应急空间与设施", description = "新增应急空间与设施" )
	public ResultVO < String > saveData ( @RequestBody @Validated ContingencySpaceFacilityDTO dto ) {
		return contingencySpaceFacilityService.saveData ( dto );
	}

	@PostMapping ( "/delete" )
	@Operation ( summary = "删除应急空间与设施", description = "删除应急空间与设施" )
	public ResultVO < String > delete ( @RequestBody List < String > ids ) {
		return contingencySpaceFacilityService.delete ( ids );
	}

	@PostMapping ( "/detail" )
	@Operation ( summary = "获取应急空间与设施详情", description = "获取应急空间与设施详情" )
	public ResultVO < ContingencySpaceFacilityVO > getDetail ( @RequestBody IdDTO idDTO ) {
		return contingencySpaceFacilityService.getDetail ( idDTO.getId () );
	}
}